//
//  LineViewController.m
//  duoduo
//
//  Created by wanghao on 16/10/28.
//  Copyright © 2016年 LX. All rights reserved.
//

#import "LineViewController.h"
#import "PoolListCell.h"
#import "Poolinfo_ViewController.h"

@interface LineViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    //轮播图的数据
    NSArray *cycleImageArr;
    UIView *headerView;
    NSArray * fromArr;
    NSArray * toArr;
    NSArray * priceArr;
}
@property (nonatomic,strong) UITableView * listTableView;
@end

@implementation LineViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    self.title = @"路线";
    fromArr = @[@"深圳南山",@"深圳西乡",@"深圳宝安",@"深圳宝安",@"深圳坪洲"];
    toArr = @[@"东莞虎门",@"深圳罗湖",@"广东惠州",@"深圳罗湖",@"广州番禺"];
    priceArr = @[@"¥ 88/人",@"¥ 38/人",@"¥ 108/人",@"¥ 35/人",@"¥ 128/人"];

    [self initTableView];
}

- (void)initTableView
{
    _listTableView =[[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight-64) style:UITableViewStylePlain];
    _listTableView.delegate = self;
    _listTableView.dataSource = self;
    _listTableView.tableFooterView.backgroundColor = LXHexColor(0xD6D6D6);
    [self.view  addSubview:_listTableView];
    [_listTableView registerNib:[UINib nibWithNibName:@"PoolListCell" bundle:nil] forCellReuseIdentifier:@"listcell"];
    _listTableView.tableFooterView = [[UIView alloc]init];

}

#pragma mark --- UITableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return fromArr.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    PoolListCell * cell = [tableView dequeueReusableCellWithIdentifier:@"listcell"];
    cell.fromAddressLabel.text = fromArr[indexPath.section];
    cell.toAddressLabel.text = toArr[indexPath.section];
    cell.priceLabel.text = priceArr[indexPath.section];
    return cell;

}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    Poolinfo_ViewController * vc = [[Poolinfo_ViewController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];


}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section == 0) {
        return 30;
    }
    return 15;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    if (section == 0) {
        UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 40)];
        view.backgroundColor = LXHexColor(0xF5F6F7);
        UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(15, 10, 80, 18)];
        label.textColor = [UIColor grayColor];
        label.text = @"匹配的路线";
        label.font = [UIFont systemFontOfSize:16];
        [view addSubview:label];
        return view;
    }
    return nil;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{

    return 80;

}

@end
